#define _CRT_SECURE_NO_WARNINGS	

/**
 * Definition for a binary tree node.
 * struct TreeNode {
 *     int val;
 *     struct TreeNode *left;
 *     struct TreeNode *right;
 * };
 */
typedef struct TreeNode TreeNode;
int arr[1001];
void Pre_Order(TreeNode* root)
{
    if (root == NULL)
    {
        return;
    }
    arr[root->val] = 1;
    Pre_Order(root->left);
    Pre_Order(root->right);
}
void Init_Array(int* arr)
{
    for (int i = 0; i < 1001; i++)
        arr[i] = 0;
}
int numColor(struct TreeNode* root)
{
    Init_Array(arr);
    int count = 0;
    Pre_Order(root);
    for (int i = 0; i < 1001; i++)
    {
        if (arr[i])
            count++;
    }
    return count;
}